using Microsoft.Xna.Framework;

namespace XeoEngine
{

    class PauseMenuScreen : MenuScreen
    {
        MenuEntry resumeGameMenuEntry;
        MenuEntry quitGameMenuEntry;
        MenuEntry optionsGameMenuEntry;

        public PauseMenuScreen()
            : base(Localizations.Strings.Paused)
        {
            resumeGameMenuEntry = new MenuEntry(Localizations.Strings.Resume);
            quitGameMenuEntry = new MenuEntry(Localizations.Strings.Quit);
            optionsGameMenuEntry = new MenuEntry(Localizations.Strings.Options);
            resumeGameMenuEntry.Selected += OnCancel;
            optionsGameMenuEntry.Selected += OptionsMenuEntrySelected;
            quitGameMenuEntry.Selected += QuitGameMenuEntrySelected;
            MenuEntries.Add(resumeGameMenuEntry);
            MenuEntries.Add(optionsGameMenuEntry);
            MenuEntries.Add(quitGameMenuEntry);
        }

        public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen)
        {
            resumeGameMenuEntry.Text = Localizations.Strings.Resume;
            optionsGameMenuEntry.Text = Localizations.Strings.Options;
            quitGameMenuEntry.Text = Localizations.Strings.Quit;
            MenuTitle = Localizations.Strings.MainMenu;
            base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen);
        }

        void QuitGameMenuEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            string message = Localizations.Strings.QuitWarn;
            MessageBoxScreen confirmQuitMessageBox = new MessageBoxScreen(message);
            confirmQuitMessageBox.Accepted += ConfirmQuitMessageBoxAccepted;
            ScreenManager.AddScreen(confirmQuitMessageBox, ControllingPlayer);
        }

        void ConfirmQuitMessageBoxAccepted(object sender, PlayerIndexEventArgs e)
        {
            LoadingScreen.Load(ScreenManager, false,"", null, new BackgroundScreen(), new MainMenuScreen());
        }

        void OptionsMenuEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            ScreenManager.AddScreen(new OptionsMenuScreen(), e.PlayerIndex);
        }
    }
}
